package conf

import (
	"gitlab.maoka-inc.com/maoka/maoka-base/config"
	"gitlab.maoka-inc.com/maoka/tool-kit/tlogger"
)

var Global *Config

type Config struct {
	Service Service `json:"service"`
	Mysql   Mysql   `json:"mysql"`
	Redis   Redis   `json:"redis"`
}

type Mysql struct {
	Minidsn  string `json:"minidsn"`
	Maokadsn string `json:"maokadsn"`
}

type Redis struct {
	Host string `json:"host"`
	DB   string `json:"db"`
	Auth string `json:"auth"`
}

type Service struct {
	ProductId int    `json:"product_id"`
	LoginUrl  string `json:"login_url"`
	GameUrl   string `json:"game_url"`
	IsDebug   bool   `json:"is_debug"`
	FromId    int    `json:"from_id"`
}

func (c *Config) Get(table, filed string, value interface{}) interface{} {
	tlogger.Sugar.Infof("table: %s, filed:%s: value:%v", table, filed, value)
	return nil
}

func Init(namespace string) {
	conf := Config{}
	err := config.LoadGlobalConfig("ind_game_robot", namespace, &conf, "")
	if err != nil {
		tlogger.Sugar.Errorf("Config Init Error: %s", err)
	}
	Global = config.GetGlobalConfig().(*Config)
}
